All Questions
11 questions
2votes
1answer
233views
How to implement Gang of Four's Lexi's Compositor-Composition?
I'm studying Design Patterns book and I was trying to understand the Composition principle in Lexi's Compositor-Composition as explained in figure 2.5, as well as how to implement it. Where the ...
2votes
1answer
181views
Loose coupling vs transparency in visitor pattern that visits composite
I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2) All of them have an Accept(Visitor) method. I have a GUI, A is the main window that consists of ...
1vote
2answers
87views
Composite Design Pattern with unequal weightage
You have a video game in which upon killing final boss you get coins that get distributed based on whether you are: Person(individual) Group(consists of individuals or groups) If reward for killing ...
0votes
1answer
1kviews
DDD & composition
I have a project to build, which has the following requirements: topup a wallet by paying money in exchange for credit; this has also the constraint of needing an approval from the finance team, if ...
4votes
4answers
3kviews
Composition over Inheritance, why not both?
I have this out of context scenario, where what I think is good practices leaves me in a situation of both implementing an interface, and using composition to do the implementation. Imagine the ...
3votes
2answers
462views
Should I nest repositories like Russian dolls?
tl;dr Can I have a repository depend on another repository, where they both implement the same interface? I am working on a website analytics system that involves getting data from different sources. ...
2votes
1answer
1kviews
Are nested private classes considered composition?
Background I am considering a design that includes a public API class containing many nested private classes. I am doing this for the following reasons: Why private nesting? They will have no use to ...
2votes
3answers
6kviews
Extending a struct. Using helper classes rather than composition
I have a struct which I want to add static methods to. Yes, you guessed right I'm talking about Datetime. It's a pretty typical requirement to add MyCustomParse. It happens to return Datetime?, so it'...
6votes
2answers
4kviews
How to replace inheritance with composition in this case?
I've recently read several articles about the advantages of the composition over inheritance. Their authors said that you can always replace inheritance with composition (to be precise, they say they ...
1vote
3answers
2kviews
Does this in the Observer pattern count as composition?
In a classic implementation of the Observer design pattern, the subject has a list of references to all of it's observers, and each observer might have a reference to it's subject. Is this considered ...
0votes
2answers
357views
Inheritance versus Composition in a business application
I have a training management and tracking system, with a high level structure as follows: We have a Role1, e.g. Manager, Shift-boss, miner, etc. and a Candidate, training for that Role. The role has ...